/** Notify.js - v0.3.1 - 2014/06/29
 * http://notifyjs.com/
 * Copyright (c) 2014 Jaime Pillora - MIT
 */
(function(t, i, n, e) {
	"use strict";
	var r, o, s, a, l, h, c, p, u, d, f, A, m, w, g, y, b, v, x, C, S, E, M, k, H, D, F, T = [].indexOf || function(t) {
		for (var i = 0, n = this.length; n > i; i++)
			if (i in this && this[i] === t) return i;
		return -1
	};
	S = "notify", C = S + "js", s = S + "!blank", M = {
		t: "top",
		m: "middle",
		b: "bottom",
		l: "left",
		c: "center",
		r: "right"
	}, m = ["l", "c", "r"], F = ["t", "m", "b"], b = ["t", "b", "l", "r"], v = {
		t: "b",
		m: null,
		b: "t",
		l: "r",
		c: null,
		r: "l"
	}, x = function(t) {
		var i;
		return i = [], n.each(t.split(/\W+/), function(t, n) {
			var r;
			return r = n.toLowerCase().charAt(0), M[r] ? i.push(r) : e
		}), i
	}, D = {}, a = {
		name: "core",
		html: '<div class="' + C + '-wrapper">\n  <div class="' + C + '-arrow"></div>\n  <div class="' + C + '-container"></div>\n</div>',
		css: "." + C + "-corner {\n  position: fixed;\n  margin: 5px;\n  z-index: 1050;\n}\n\n." + C + "-corner ." + C + "-wrapper,\n." + C + "-corner ." + C + "-container {\n  position: relative;\n  display: block;\n  height: inherit;\n  width: inherit;\n  margin: 3px;\n}\n\n." + C + "-wrapper {\n  z-index: 1;\n  position: absolute;\n  display: inline-block;\n  height: 0;\n  width: 0;\n}\n\n." + C + "-container {\n  display: none;\n  z-index: 1;\n  position: absolute;\n}\n\n." + C + "-hidable {\n  cursor: pointer;\n}\n\n[data-notify-text],[data-notify-html] {\n  position: relative;\n}\n\n." + C + "-arrow {\n  position: absolute;\n  z-index: 2;\n  width: 0;\n  height: 0;\n}"
	}, H = {
		"border-radius": ["-webkit-", "-moz-"]
	}, f = function(t) {
		return D[t]
	}, o = function(i, e) {
		var r, o, s, a;
		if (!i) throw "Missing Style name";
		if (!e) throw "Missing Style definition";
		if (!e.html) throw "Missing Style HTML";
		return (null != (a = D[i]) ? a.cssElem : void 0) && (t.console && console.warn("" + S + ": overwriting style '" + i + "'"), D[i].cssElem.remove()), e.name = i, D[i] = e, r = "", e.classes && n.each(e.classes, function(t, i) {
			return r += "." + C + "-" + e.name + "-" + t + " {\n", n.each(i, function(t, i) {
				return H[t] && n.each(H[t], function(n, e) {
					return r += "  " + e + t + ": " + i + ";\n"
				}), r += "  " + t + ": " + i + ";\n"
			}), r += "}\n"
		}), e.css && (r += "/* styles for " + e.name + " */\n" + e.css), r && (e.cssElem = y(r), e.cssElem.attr("id", "notify-" + e.name)), s = {}, o = n(e.html), u("html", o, s), u("text", o, s), e.fields = s
	}, y = function(t) {
		var i;
		i = l("style"), i.attr("type", "text/css"), n("head").append(i);
		try {
			i.html(t)
		} catch (e) {
			i[0].styleSheet.cssText = t
		}
		return i
	}, u = function(t, i, e) {
		var r;
		return "html" !== t && (t = "text"), r = "data-notify-" + t, p(i, "[" + r + "]").each(function() {
			var i;
			return i = n(this).attr(r), i || (i = s), e[i] = t
		})
	}, p = function(t, i) {
		return t.is(i) ? t : t.find(i)
	}, E = {
		clickToHide: !0,
		autoHide: !0,
		autoHideDelay: 5e3,
		arrowShow: !0,
		arrowSize: 5,
		breakNewLines: !0,
		elementPosition: "bottom",
		globalPosition: "top right",
		style: "bootstrap",
		className: "error",
		showAnimation: "slideDown",
		showDuration: 400,
		hideAnimation: "slideUp",
		hideDuration: 200,
		gap: 5
	}, g = function(t, i) {
		var e;
		return e = function() {}, e.prototype = t, n.extend(!0, new e, i)
	}, h = function(t) {
		return n.extend(E, t)
	}, l = function(t) {
		return n("<" + t + "></" + t + ">")
	}, A = {}, d = function(t) {
		var i;
		return t.is("[type=radio]") && (i = t.parents("form:first").find("[type=radio]").filter(function(i, e) {
			return n(e).attr("name") === t.attr("name")
		}), t = i.first()), t
	}, w = function(t, i, n) {
		var r, o;
		if ("string" == typeof n) n = parseInt(n, 10);
		else if ("number" != typeof n) return;
		if (!isNaN(n)) return r = M[v[i.charAt(0)]], o = i, t[r] !== e && (i = M[r.charAt(0)], n = -n), t[i] === e ? t[i] = n : t[i] += n, null
	}, k = function(t, i, n) {
		if ("l" === t || "t" === t) return 0;
		if ("c" === t || "m" === t) return n / 2 - i / 2;
		if ("r" === t || "b" === t) return n - i;
		throw "Invalid alignment"
	}, c = function(t) {
		return c.e = c.e || l("div"), c.e.text(t).html()
	}, r = function() {
		function t(t, i, e) {
			"string" == typeof e && (e = {
				className: e
			}), this.options = g(E, n.isPlainObject(e) ? e : {}), this.loadHTML(), this.wrapper = n(a.html), this.options.clickToHide && this.wrapper.addClass("" + C + "-hidable"), this.wrapper.data(C, this), this.arrow = this.wrapper.find("." + C + "-arrow"), this.container = this.wrapper.find("." + C + "-container"), this.container.append(this.userContainer), t && t.length && (this.elementType = t.attr("type"), this.originalElement = t, this.elem = d(t), this.elem.data(C, this), this.elem.before(this.wrapper)), this.container.hide(), this.run(i)
		}
		return t.prototype.loadHTML = function() {
			var t;
			return t = this.getStyle(), this.userContainer = n(t.html), this.userFields = t.fields
		}, t.prototype.show = function(t, i) {
			var n, r, o, s, a, l = this;
			if (r = function() {
					return t || l.elem || l.destroy(), i ? i() : e
				}, a = this.container.parent().parents(":hidden").length > 0, o = this.container.add(this.arrow), n = [], a && t) s = "show";
			else if (a && !t) s = "hide";
			else if (!a && t) s = this.options.showAnimation, n.push(this.options.showDuration);
			else {
				if (a || t) return r();
				s = this.options.hideAnimation, n.push(this.options.hideDuration)
			}
			return n.push(r), o[s].apply(o, n)
		}, t.prototype.setGlobalPosition = function() {
			var t, i, e, r, o, s, a, h;
			return h = this.getPosition(), a = h[0], s = h[1], o = M[a], t = M[s], r = a + "|" + s, i = A[r], i || (i = A[r] = l("div"), e = {}, e[o] = 0, "middle" === t ? e.top = "45%" : "center" === t ? e.left = "45%" : e[t] = 0, i.css(e).addClass("" + C + "-corner"), n("body").append(i)), i.prepend(this.wrapper)
		}, t.prototype.setElementPosition = function() {
			var t, i, r, o, s, a, l, h, c, p, u, d, f, A, g, y, x, C, S, E, H, D, z, Q, B, R, N, P, U;
			for (z = this.getPosition(), E = z[0], C = z[1], S = z[2], u = this.elem.position(), h = this.elem.outerHeight(), d = this.elem.outerWidth(), c = this.elem.innerHeight(), p = this.elem.innerWidth(), Q = this.wrapper.position(), s = this.container.height(), a = this.container.width(), A = M[E], y = v[E], x = M[y], l = {}, l[x] = "b" === E ? h : "r" === E ? d : 0, w(l, "top", u.top - Q.top), w(l, "left", u.left - Q.left), U = ["top", "left"], B = 0, N = U.length; N > B; B++) H = U[B], g = parseInt(this.elem.css("margin-" + H), 10), g && w(l, H, g);
			if (f = Math.max(0, this.options.gap - (this.options.arrowShow ? r : 0)), w(l, x, f), this.options.arrowShow) {
				for (r = this.options.arrowSize, i = n.extend({}, l), t = this.userContainer.css("border-color") || this.userContainer.css("background-color") || "white", R = 0, P = b.length; P > R; R++) H = b[R], D = M[H], H !== y && (o = D === A ? t : "transparent", i["border-" + D] = "" + r + "px solid " + o);
				w(l, M[y], r), T.call(b, C) >= 0 && w(i, M[C], 2 * r)
			} else this.arrow.hide();
			return T.call(F, E) >= 0 ? (w(l, "left", k(C, a, d)), i && w(i, "left", k(C, r, p))) : T.call(m, E) >= 0 && (w(l, "top", k(C, s, h)), i && w(i, "top", k(C, r, c))), this.container.is(":visible") && (l.display = "block"), this.container.removeAttr("style").css(l), i ? this.arrow.removeAttr("style").css(i) : e
		}, t.prototype.getPosition = function() {
			var t, i, n, e, r, o, s, a;
			if (i = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition), t = x(i), 0 === t.length && (t[0] = "b"), n = t[0], 0 > T.call(b, n)) throw "Must be one of [" + b + "]";
			return (1 === t.length || (e = t[0], T.call(F, e) >= 0 && (r = t[1], 0 > T.call(m, r))) || (o = t[0], T.call(m, o) >= 0 && (s = t[1], 0 > T.call(F, s)))) && (t[1] = (a = t[0], T.call(m, a) >= 0 ? "m" : "l")), 2 === t.length && (t[2] = t[1]), t
		}, t.prototype.getStyle = function(t) {
			var i;
			if (t || (t = this.options.style), t || (t = "default"), i = D[t], !i) throw "Missing style: " + t;
			return i
		}, t.prototype.updateClasses = function() {
			var t, i;
			return t = ["base"], n.isArray(this.options.className) ? t = t.concat(this.options.className) : this.options.className && t.push(this.options.className), i = this.getStyle(), t = n.map(t, function(t) {
				return "" + C + "-" + i.name + "-" + t
			}).join(" "), this.userContainer.attr("class", t)
		}, t.prototype.run = function(t, i) {
			var r, o, a, l, h, u = this;
			if (n.isPlainObject(i) ? n.extend(this.options, i) : "string" === n.type(i) && (this.options.className = i), this.container && !t) return this.show(!1), e;
			if (this.container || t) {
				o = {}, n.isPlainObject(t) ? o = t : o[s] = t;
				for (a in o) r = o[a], l = this.userFields[a], l && ("text" === l && (r = c(r), this.options.breakNewLines && (r = r.replace(/\n/g, "<br/>"))), h = a === s ? "" : "=" + a, p(this.userContainer, "[data-notify-" + l + h + "]").html(r));
				return this.updateClasses(), this.elem ? this.setElementPosition() : this.setGlobalPosition(), this.show(!0), this.options.autoHide ? (clearTimeout(this.autohideTimer), this.autohideTimer = setTimeout(function() {
					return u.show(!1)
				}, this.options.autoHideDelay)) : e
			}
		}, t.prototype.destroy = function() {
			return this.wrapper.remove()
		}, t
	}(), n[S] = function(t, i, e) {
		return t && t.nodeName || t.jquery ? n(t)[S](i, e) : (e = i, i = t, new r(null, i, e)), t
	}, n.fn[S] = function(t, i) {
		return n(this).each(function() {
			var e;
			return e = d(n(this)).data(C), e ? e.run(t, i) : new r(n(this), t, i)
		}), this
	}, n.extend(n[S], {
		defaults: h,
		addStyle: o,
		pluginOptions: E,
		getStyle: f,
		insertCSS: y
	}), n(function() {
		return y(a.css).attr("id", "core-notify"), n(i).on("click", "." + C + "-hidable", function() {
			return n(this).trigger("notify-hide")
		}), n(i).on("notify-hide", "." + C + "-wrapper", function() {
			var t;
			return null != (t = n(this).data(C)) ? t.show(!1) : void 0
		})
	})
})(window, document, jQuery), $.notify.addStyle("bootstrap", {
	html: "<div>\n<span data-notify-text></span>\n</div>",
	classes: {
		base: {
			"font-size": "14px",
			"font-weight": "bold",
			padding: "6px 14px 5px 14px",
			"background-color": "#fcf8e3",
			border: "1px solid #fbeed5",
			"border-radius": "4px",
			"white-space": "nowrap",
			"padding-left": "25px",
			"background-repeat": "no-repeat",
			"background-position": "3px 4px"
		},
		error: {
			color: "#B94A48",
			"background-color": "#F2DEDE",
			"border-color": "#EED3D7",
			"background-image": "url()"
		},
		success: {
			color: "#468847",
			"background-color": "#DFF0D8",
			"border-color": "#D6E9C6",
			"background-image": "url()"
		},
		info: {
			color: "#3A87AD",
			"background-color": "#D9EDF7",
			"border-color": "#BCE8F1",
			"background-image": "url()"
		},
		warn: {
			color: "#C09853",
			"background-color": "#FCF8E3",
			"border-color": "#FBEED5",
			"background-image": "url()"
		}
	}
});